|
|
|
|
|
|
|
Learn error-handling techniques |
|
|
|
|
|
|
|
|
Learn the different methods for handling errors |
|
|
|
|
|
|
|
|
Create a generic error handler |
|
|
|
|
|
|
|
|
Sample Project File: \Chapter17\Errors.vbp |
|
|
|
|
|
|
|
|
How Visual Basic Handles Error |
|
|
|
|
|
|
|
|
If Visual Basic detects an error in your program, youll see a dialog box appear that tells you what the error is and allows you to go into debug mode, end the program, or get help. As you can see from looking at Figure 17.1, this dialog box is not very descriptive, and it wont give the user a clue as to how to handle this error. As a result, youll probably want to add your own error handling to your applications. |
|
|
|
 |
|
|
|
|
NOTE Only when youre running from the Visual Basic development environment will you have all the command buttons shown in Figure 17.1. If youve created an EXE file, the only button you have to respond to is the OK button. When you click this button, the Visual Basic program will end very abruptly. |
|
|
|
|
|
|
|
|
Figure 17.1
The Visual Basic error dialog box. |
|
|
|
|
|
|
|
|
You can see this error dialog box by running the sample project for this chapter and clicking the Divide Error command button and then clicking the VBError command button on the Divide By Zero form. |
|
|
|
|
|